package com.example.rbac.controller.restful;

import com.example.rbac.entity.defefult.Result;
import com.example.rbac.uitls.HttpUtils;
import com.example.rbac.uitls.ResultUtil;
import com.example.rbac.uitls.ThreadUtils;
import com.google.gson.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;


@RestController
@RequestMapping("/api/test")
public class testRestController {

    @Autowired
    private HttpUtils httpUtils;

    @GetMapping("testHttpClient")
    public Result testHttpClient(){
        try {
            String resp = httpUtils.doGet("http://127.0.0.1:8081/api/User/page");
            JsonObject jsonObject = httpUtils.toJsonObj(resp);
            return ResultUtil.success(jsonObject.toString());
        }catch (Exception e){
            return ResultUtil.erorr(500, e.getMessage().toString());
        }
    }


}
